<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>查询</title>
    <style>
        h1,
        h3,
        p#cp {
            text-align: center;
        }

        table {
            margin: 0 auto;
            text-align: center;
            font-size: 18px;
        }

        table td {
            width: 60px;
        }
    </style>
</head>

<body>
    <h1 id="NAME">姓名：&nbsp;；序号:&nbsp;</h1>
    <p id="cp">查询： <input type="text" onkeyup="showNo(this.value)" placeholder="请输入名字"></p>
    <h3>名单</h3>
    <table>
        <tbody id="TBODY">
        </tbody>
    </table>
    <script>
        var names = [
            { name: '甲', no: 1 },
            { name: '乙', no: 2 },
            { name: '丙', no: 3 },
            { name: '丁', no: 4 },
            { name: '戊', no: 5 },
            { name: '己', no: 6 },
            { name: '庚', no: 7 },
            { name: '辛', no: 8 },
            { name: '壬', no: 9 },
            { name: '癸', no: 10 },

        ];
        var NAME = document.getElementById('NAME');
        var TBODY = document.getElementById('TBODY');
        function showNo(nm) {
            for (var i = 0; i < names.length; i++) {
                if (names[i].name === nm) {
                    NAME.textContent = '姓名：' + names[i].name + '；序号: ' + names[i].no;
                    return;
                }
            }
        }

        function init() {
            var innerHTML = '<tr><td>';
            for (var i = 0; i < names.length; i++) {
                innerHTML += names[i].name;
                if (i % 4 === 3) {
                    innerHTML += '</td></tr><tr><td>';
                } else {
                    innerHTML += '</td><td>';
                }
            }

            TBODY.innerHTML = innerHTML;
        }

        init();
    </script>
</body>

</html>